<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:composition template="/shared/_layout.xhtml">
        <ui:define name="title">
            <h:outputText value="#{lang._shopping_index_title}"/>
        </ui:define>
        <ui:define name="css">
            <h:outputStylesheet name="form.css" library="css" />
            <h:outputStylesheet name="index.css" library="css/shopping/validation" />
        </ui:define>
        <ui:define name="content">
            <f:event listener="#{account.isNotLogged()}" type="preRenderView" />
            <f:event listener="#{shoppingCart.hasNotItems()}" type="preRenderView" />
            <article>
                <h1>
                    <h:outputText value="#{lang._shopping_validation_shopping}"/>
                </h1>
                <h:form>
                    <section>
                        <h2>
                            <h:outputText value="#{lang._shopping_validation_summary}"/>
                        </h2>
                        <h:dataTable class="orders" value="#{shoppingCart.items}" var="entry" columnClasses="orders-name, orders-name, orders-price, orders-quantity">
                            <h:column>
                                <f:facet name="header"></f:facet>
                                <h:graphicImage library="img/books" name="#{entry.article.idArticles.image}" height="75" width="50"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    Nom
                                </f:facet>
                                <h:outputText value="#{entry.article.idArticles.name}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    Prix
                                </f:facet>
                                <h:outputText value="#{entry.article.idArticles.price}€"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    Quantité
                                </f:facet>
                                <h:outputText value="#{entry.quantity}"/>
                            </h:column>
                        </h:dataTable>
                    </section>
                    <section>
                        <h2>
                            <h:outputText value="#{lang._shopping_validation_yours_informations}"/>
                        </h2>
                        <table>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._shopping_validation_name}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.firstname}, "/>
                                    <h:outputText value="#{account.user.lastname}" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._shopping_validation_address}" />
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.address}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._shopping_validation_country}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.country}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._shopping_validation_city}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.city}"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <b>
                                        <h:outputText value="#{lang._shopping_validation_zipcode}"/>
                                    </b>
                                </td>
                                <td>
                                    <h:outputText value="#{account.user.zip}"/>
                                </td>
                            </tr>
                        </table>
                        <p>
                            <h:outputLabel for="credit-card" value="#{lang._shopping_validation_credit_card}"/>
                            <h:inputText id="credit-card" label="#{lang._shopping_validation_credit_card}" value="#{banking.creditCard}" required="true">
                                <f:validator validatorId="creditCardValidator"/>
                            </h:inputText>
                        </p>
                    </section>
                    <section>
                        <h2>
                            <h:outputText value="#{lang._shopping_validation_confirmation}"/>
                        </h2>
                        <p>
                            <h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage"/>
                        </p>
                        <p>
                            <h:outputText value="#{lang._shopping_validation_before_buy}"/>
                        </p>
                        <p>
                            <h:commandButton action="#{shoppingCart.buy(account.user)}" value="#{lang._shopping_validation_buy}"/>
                        </p>
                    </section>
                </h:form>
            </article>
        </ui:define>
    </ui:composition>
</html>

